Skip to content

Translate import declarations into calls to require() in beforeInit.#11

Closed
thomsbg wants to merge 2 commits intomarcello3d:masterfrom
thomsbg:master
Closed

Translate import declarations into calls to require() in beforeInit.#11
thomsbg wants to merge 2 commits intomarcello3d:masterfrom
thomsbg:master

Conversation

@thomsbg
Copy link
Copy Markdown

@thomsbg thomsbg commented Sep 11, 2014

Import hrefs are assumed to be relative to the current file, and so
the call to require has ./ prepended. e.g.

<link rel="ractive" href="test.ract" />
require('./test.ract');

If a beforeInit callback was specified in the component, it will be
called after the sub-components have been set into options. See the
new test case for an example.

Also, I refactored things slightly to branching on if (component.script). This causes var component = module to always be output, and the use of component.exports over just exports. Please let me know if that's a problem.

Import hrefs are assumed to be relative to the current file, and so
the call to require has `./` prepended. e.g.

    <link rel="ractive" href="test.ract" />
    require('./test.ract');

If a beforeInit callback was specified in the component, it will be
called after the sub-components have been set into options. See the
new test case for an example.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with how beforeInit works, is it possible for options.components to already exist at this point?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yes I think so, if you were to instantiate your component like so: new CustomComponent({ components: { ... } })

I'll revise to not overwrite any passed in options.

@thomsbg
Copy link
Copy Markdown
Author

thomsbg commented Sep 11, 2014

Ah, now I see #5. I didn't realize that component.exports.components would work, and so I think @MartinKolarik has a bit cleaner implementation. Let's concentrate our thoughts there.

@thomsbg thomsbg closed this Sep 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants